#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 1e5 + 10, INF = 0x3f3f3f3f;

int n;
string s, t;
int f[2][N];

void solve()
{
    cin >> s;t = s;
    n = s.length();
    reverse(t.begin(), t.end());
    s = " " + s; t = " " + t;

    int now = 0, last = 1;
    for (int i = 1;i <= n;i++) {
        for (int j = 1;j <= n;j++) {
            if (s[i] == t[j]) f[now][j] = f[last][j - 1] + 1;
            else f[now][j] = max(f[last][j], f[now][j - 1]);
        }
        swap(now, last);
    }
    cout << n - f[last][n];
}

signed main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}